﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;

namespace LCTMoodle.Models.ViewModels
{
    public class NguoiDungViewModel : Model
    {
        public int ma { get; set; }
        public string tenDangNhap { get; set; }
        public string matKhau { get; set; }
        public string email { get; set; }
        public string hoTen { get; set; }
        public string soDienThoai { get; set; }
        public string loaiNguoidung { get; set; }

        public override void assignModel(SqlDataReader dr)
        {
            for (int i = 0; i < dr.FieldCount; i++)
            {
                switch (dr.GetName(i))
                {
                    case "Ma":
                        ma = (dr.IsDBNull(i)) ? 0 : dr.GetInt32(i); break;
                    case "TenDangNhap":
                        tenDangNhap = (dr.IsDBNull(i)) ? null : dr.GetString(i); break;
                    case "MatKhau":
                        matKhau = (dr.IsDBNull(i)) ? null : dr.GetString(i); break;
                    case "Email":
                        email = (dr.IsDBNull(i)) ? null : dr.GetString(i); break;
                    case "HoTen":
                        hoTen = (dr.IsDBNull(i)) ? null : dr.GetString(i); break;
                    case "SoDienThoai":
                        soDienThoai = (dr.IsDBNull(i)) ? null : dr.GetString(i); break;
                    case "LoaiNguoiDung":
                        loaiNguoidung = (dr.IsDBNull(i)) ? null : dr.GetString(i); break;
                    default:
                        break;
                }
            }
        }
    }
}